<?php

namespace App\Models\Strator;

use App\Models\Traits\DateTimeTrait;
use App\Models\Traits\ModelSearchTrait;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class StratorDepartment extends Model
{
    use SoftDeletes, DateTimeTrait, ModelSearchTrait;

    protected $dateFormat = 'Y-m-d H:i:s';
    protected $guarded = [];

    //
    public function searchConditions():array{
        return [
            ['department_name','like'],
            ['department_code','='],
            ['pid','='],
        ];
    }

    //
    public function parent(){
        return $this->belongsTo(StratorDepartment::class,'pid','id');
    }
    //
    public function positions(){
        return $this->hasMany(StratorPosition::class,'department_id','id');
    }
    //
    public function user(){
        return $this->hasMany(Strator::class,'department_id','id');
    }


}
